import { use } from 'chai';

import React, { useEffect, useRef, useState } from 'react';
import {
  Button,
  View,
  StyleSheet,
  ScrollView,
  TouchableOpacity,
  Text,
} from 'react-native';
import { Tester, TestSuite, TestCase } from '@rnoh/testerino';
import RNShare from 'react-native-share';
// import buttonIcon from './button.png';

export function RNShareExample() {
  let [showOverlay, setShowOverlay] = useState<boolean>(false);
  let [showSheet, setShowSheet] = useState<boolean>(false);
  let [showShareSheet, setShowShareSheet] = useState<boolean>(false);
  let [saveToFiles, setSaveToFiles] = useState<boolean>(false);
  let [shareOptions, setShareOptions] = useState<string[]>([]);
  let [excludedActivityTypes, setExcludedActivityTypes] = useState<string[]>(['0', '1', '2', '3', '4']);
  let [title, setTitle] = useState<string>('分享标题');
  let [share, setShare] = useState<string>('');
  let [appId, setAppId] = useState<string>('');
  let [viewHeight, setViewHeight] = useState(500);
  let [subject, setSubject] = useState<string>('分享的内容');
  let [url, setUrl] = useState<string>(
    'https://developer.huawei.com/consumer/cn/',
  );
  let [imageUrl2] = useState<string>(
    'https://developer.huawei.com/allianceCmsResource/resource/HUAWEI_Developer_VUE/images/homeNew/sy-yy-pc.jpeg',
  );
  let [imageUrl] = useState<string>(
    'https://developer.huawei.com/images/new-content/develop/img_DLP_develop_gailan_ArkUI.png',
  );
  let [base64Url] = useState<string>(
    '',
  );
  let [videoUrl] = useState<string>('https://vjs.zencdn.net/v/oceans.mp4');
  // let [docUrl] = useState<string>('file://com.rnoh.tester/data/storage/el1/base/cache/video_file/d2.doc');
  // let [txtUrl] = useState<string>('file://com.rnoh.tester/data/storage/el1/base/cache/video_file/c1.txt');
  // let [localImage] = useState<string>('file://com.rnoh.tester/data/storage/el1/base/cache/image_file/a1.png');
  const getShareTypeArr = (options: any) => {
    const shareArr: string[] = ['testshare'];
    let social: { [key: string]: string } = options;
    for (let key in social) {
      shareArr.push(social[key]);
    }
    return shareArr;
  };

  useEffect(() => {
    const arr = getShareTypeArr(RNShare.Social);
    setShareOptions(arr);
  }, []);
  const getShareAction = async (option: string) => {
    if (option === RNShare.Social.FACEBOOK_STORIES) {
      setAppId('284882215')
    } else if (option === RNShare.Social.INSTAGRAM_STORIES) {
      setAppId('389801252')
    } else {
      setAppId('')
    }

    setShare(option);
  };
  const shareAction = async (options: any) => {
    try {
      const res = await RNShare.shareSingle(options);
      console.log('###Tester000', res);
      return res?.success;
    } catch (error) {
      console.log('###Tester111', JSON.stringify(error));
      return false;
    }
  };
  const openAction = async (options: any) => {
    try {
      const res = await RNShare.open(options);
      console.log('###Tester00', res);
      return res?.success;
    } catch (error) {
      console.log('###Tester111', JSON.stringify(error));
      return false;
    }
  };

  const isPackageInstalled = async () => {
    try {
      const res = await RNShare.isPackageInstalled(share);
      console.log('###Tester', JSON.stringify(res));
      return res?.isInstalled;
    } catch (error) {
      console.log('###Tester', JSON.stringify(error));
      return false;
    }
  };

  const handleOpenOverlay = () => {
    setShowOverlay(true);
    setViewHeight(0)
  };

  const handleCloseOverlay = () => {
    setShowOverlay(false);
    setViewHeight(500)
  };

  const handleOpenSheet = () => {
    setShowSheet(true);
    setViewHeight(0)
  };

  const handleCloseSheet = () => {
    setShowSheet(false);
  };

  const handleOpenShareSheet = () => {
    setShowShareSheet(true);
    setViewHeight(0)
  };

  const handleCloseShareSheet = () => {
    setShowShareSheet(false);
  };

  const [visible, setVisible] = useState(true);

  return (
    <Tester>
      <ScrollView style={[styles.content, { height: viewHeight }]}>
        <View style={styles.linkView}>
          <Text>请选择分享的三方APP</Text>
          <ScrollView horizontal={true} showsHorizontalScrollIndicator={true}>
            <View style={styles.linkContent}>
              {shareOptions.map(item => {
                return (
                  <Text
                    style={
                      share === item ? styles.linkTextSelected : styles.linkText
                    }
                    key={item}
                    onPress={() => {
                      getShareAction(item);
                    }}>
                    {item}
                  </Text>
                );
              })}
            </View>
          </ScrollView>
        </View>
         <TestSuite name="验证shareSingle接口-三方分享链接">
          <TestCase
            itShould="测试social参数-指定第三方APP"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text numberOfLines={10} style={styles.inputView}>
                    {JSON.stringify({
                      social: share,
                      url,
                    })}
                  </Text>
                  <Button
                    key="openImageAction1"
                    title="测试social参数"
                    onPress={async () => {
                      const res = await shareAction({
                        social: share,
                        url,

                      });
                      setState(res);
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase social parameter', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>

        <TestSuite name="验证shareSingle接口-三方分享图片">
          <TestCase
            itShould="测试url参数-图片分享"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text numberOfLines={10} style={styles.inputView}>
                    {JSON.stringify({
                      social: share,
                      url: imageUrl,
                    })}
                  </Text>
                  <Button
                    key="openImageAction2"
                    title="测试图片url参数"
                    onPress={async () => {
                      const res = await shareAction({
                        social: share,
                        url: imageUrl,
                      });
                      setState(res);
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase image url parameter', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>

        <TestSuite name="验证shareSingle接口-三方分享base64图片">
          <TestCase
            itShould="测试urls参数-base64图片分享"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text numberOfLines={10} style={styles.inputView}>
                    {JSON.stringify({
                      social: share,
                      urls: [base64Url, base64Url],
                    })}
                  </Text>
                  <Button
                    key="openImageAction22"
                    title="测试base64图片分享"
                    onPress={async () => {
                      const res = await shareAction({
                        social: share,
                        urls: [base64Url, base64Url],
                      });
                      setState(res);
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase base64 image parameter', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>

        <TestSuite name="验证type接口-三方分享视频">
          <TestCase
            itShould="测试视频分享"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text numberOfLines={10} style={styles.inputView}>
                    {JSON.stringify({
                      social: share,
                      url: videoUrl,
                    })}
                  </Text>
                  <Button
                    key="openImageAction741"
                    title="测试视频分享"
                    onPress={async () => {
                      const res = await shareAction({
                        social: share,
                        url: videoUrl,
                      });
                      setState(res);
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase video parameter', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>

        <TestSuite name="验证shareSingle接口-title参数">
          <TestCase
            itShould="测试title参数-分享标题"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text numberOfLines={10} style={styles.inputView}>
                    {JSON.stringify({
                      social: share,
                      url,
                      title: '自定义分享标题',
                    })}
                  </Text>
                  <Button
                    key="testTitleParameter"
                    title="测试title参数"
                    onPress={async () => {
                      // 添加日志输出，验证参数传递
                      console.log('###测试title参数 - 传递的参数:', JSON.stringify({
                        social: share,
                        url,
                        title: '自定义分享标题',
                      }, null, 2));

                      const res = await shareAction({
                        social: share,
                        url,
                        title: '自定义分享标题',
                      });

                      // 输出分享结果，检查是否包含title相关信息
                      console.log('###测试title参数 - 分享结果:', JSON.stringify(res, null, 2));
                      setState(res);
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase title parameter result', state);
              // 验证分享操作是否成功执行
              expect(state).to.be.true;
            }}
          />
        </TestSuite>

        <TestSuite name="验证shareSingle接口-subject参数">
          <TestCase
            itShould="测试subject参数-分享主题"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text numberOfLines={10} style={styles.inputView}>
                    {JSON.stringify({
                      social: share,
                      url,
                      subject: '自定义分享主题',
                    })}
                  </Text>
                  <Button
                    key="testSubjectParameter"
                    title="测试subject参数"
                    onPress={async () => {
                      const res = await shareAction({
                        social: share,
                        url,
                        subject: '自定义分享主题',
                      });
                      setState(res);
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase subject parameter', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>

        <TestSuite name="验证shareSingle接口-message参数">
          <TestCase
            itShould="测试message参数-消息内容"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text numberOfLines={10} style={styles.inputView}>
                    {JSON.stringify({
                      social: share,
                      url,
                      message: '自定义消息内容',
                    })}
                  </Text>
                  <Button
                    key="testMessageParameter"
                    title="测试message参数"
                    onPress={async () => {
                      const res = await shareAction({
                        social: share,
                        url,
                        message: '自定义消息内容',
                      });
                      setState(res);
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase message parameter', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>
        <TestSuite name="验证shareSingle接口-message参数">
          <TestCase
            itShould="测试recipient参数-接收短信消息的号码"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text numberOfLines={10} style={styles.inputView}>
                    {JSON.stringify({
                      social: share,
                      url,
                      recipient: '123456789',
                    })}
                  </Text>
                  <Button
                    key="testRecipient参数Parameter"
                    title="测试测试recipient参数参数"
                    onPress={async () => {
                      const res = await shareAction({
                        social: share,
                        url,
                        recipient: '123456789',
                      });
                      setState(res);
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase message parameter', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>
        <TestSuite name="验证shareSingle接口-filename参数">
          <TestCase
            itShould="测试filename参数-路径文件名"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text numberOfLines={10} style={styles.inputView}>
                    {JSON.stringify({
                      social: share,
                      url,
                      filename: 'test.txt',
                    })}
                  </Text>
                  <Button
                    key="testFilename参数Parameter"
                    title="测试filename参数"
                    onPress={async () => {
                      const res = await shareAction({
                        social: share,
                        url,
                        filename: 'test.txt',
                      });
                      setState(res);
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase message parameter', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>
        <TestSuite name="验证shareSingle接口-三方分享视频">
          <TestCase
            itShould="true"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text numberOfLines={10} style={styles.inputView}>
                    {JSON.stringify({
                      social: share,
                      url: videoUrl,
                      title,
                      subject,
                      appId,
                      message: '短信消息',
                      recipient: '123456789',
                      email: 'lihonggang11@h-partners.com',
                    })}
                  </Text>
                  <Button
                    key="openImageAction741"
                    title="三方分享视频"
                    onPress={async () => {
                      const res = await shareAction({
                        social: share,
                        url: videoUrl,
                        title,
                        subject,
                        message: '短信消息',
                        recipient: '123456789',
                        email: 'lihonggang11@h-partners.com',
                      });
                      setState(res);
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>
        <TestSuite name="验证open-系统分享链接">
          <TestCase
            itShould="true"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text numberOfLines={10} style={styles.inputView}>
                    {JSON.stringify({
                      title,
                      subject,
                      url: url,
                      saveToFiles: false,
                      message: '短信消息',
                      recipient: '123456789',
                      email: 'lihonggang11@h-partners.com',
                    })}
                  </Text>
                  <Button
                    key="openAction1"
                    title="系统分享链接"
                    onPress={async () => {
                      const res = await openAction({
                        title,
                        subject,
                        url,
                        saveToFiles: false,
                        message: '短信消息',
                        recipient: '123456789',
                        email: 'lihonggang11@h-partners.com',
                      });
                      setState(res);
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>
        <TestSuite name="验证open-系统分享网络图片">
          <TestCase
            itShould="true"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text numberOfLines={10} style={styles.inputView}>
                    {JSON.stringify({
                      title,
                      subject,
                      url: imageUrl,
                      saveToFiles: false,
                      message: '短信消息',
                      recipient: '123456789',
                      email: 'lihonggang11@h-partners.com',
                    })}
                  </Text>
                  <Button
                    key="openAction2"
                    title="系统分享网络图片"
                    onPress={async () => {
                      const res = await openAction({
                        title,
                        subject,
                        url: imageUrl,
                        saveToFiles: false,
                        message: '短信消息',
                        recipient: '123456789',
                        email: 'lihonggang11@h-partners.com',
                      });
                      setState(res);
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>
        <TestSuite name="验证open-系统分享Base64图片">
          <TestCase
            itShould="true"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text numberOfLines={10} style={styles.inputView}>
                    {JSON.stringify({
                      type: 'image/png',
                      title,
                      filename: 'test',
                      subject,
                      url: base64Url,
                      message: '短信消息',
                      recipient: '123456789',
                      email: 'lihonggang11@h-partners.com',
                    })}
                  </Text>
                  <Button
                    key="openAction22"
                    title="系统分享Base64图片"
                    onPress={async () => {
                      if (excludedActivityTypes.length == 5) {
                        setExcludedActivityTypes(['0'])
                      } else {
                        setExcludedActivityTypes(['0', '1', '2', '3', '4'])
                      }
                      const res = await openAction({
                        type: 'image/png',
                        title,
                        filenames: ['test', 'test2'],
                        subject,
                        urls: [base64Url, base64Url],
                        failOnCancel: false,
                        excludedActivityTypes: excludedActivityTypes,
                        message: '短信消息',
                        recipient: '123456789',
                        email: 'lihonggang11@h-partners.com',
                      });
                      setState(res);
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>
        <TestSuite name="验证open-系统分享Base64图片(files)">
          <TestCase
            itShould="true"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text numberOfLines={10} style={styles.inputView}>
                    {JSON.stringify({
                      type: 'image/png',
                      title,
                      filename: 'test',
                      subject,
                      saveToFiles: !saveToFiles,
                      message: '短信消息',
                      recipient: '123456789',
                      email: 'lihonggang11@h-partners.com',
                      url: base64Url,
                    })}
                  </Text>
                  <Button
                    key="openAction22"
                    title="系统分享Base64图片(file)"
                    onPress={async () => {
                      if (saveToFiles) {
                        setSaveToFiles(false)
                      } else {
                        setSaveToFiles(true)
                      }

                      const res = await openAction({
                        type: 'image/png',
                        title: title,
                        filename: 'test',
                        saveToFiles: saveToFiles,
                        failOnCancel: true,
                        message: '短信消息',
                        recipient: '123456789',
                        email: 'lihonggang11@h-partners.com',
                        subject: subject,
                        url: base64Url
                      });
                      setState(res);
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>
        <TestSuite name="验证open-系统分享视频">
          <TestCase
            itShould="true"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text numberOfLines={10} style={styles.inputView}>
                    {JSON.stringify({
                      title,
                      subject,
                      url: videoUrl,
                      saveToFiles: false,
                      message: '短信消息',
                      recipient: '123456789',
                      email: 'lihonggang11@h-partners.com',
                    })}
                  </Text>
                  <Button
                    key="openAction3"
                    title="系统分享视频"
                    onPress={async () => {
                      const res = await openAction({
                        title,
                        subject,
                        url: videoUrl,
                        saveToFiles: false,
                        message: '短信消息',
                        recipient: '123456789',
                        email: 'lihonggang11@h-partners.com',
                      });
                      setState(res);
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>
        <TestSuite name="验证open-系统分享多条文件路径">
          <TestCase
            itShould="true"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text numberOfLines={10} style={styles.inputView}>
                    {JSON.stringify({
                      title,
                      subject,
                      urls: [url, imageUrl, imageUrl2],
                      saveToFiles: false,
                      message: '短信消息',
                      recipient: '123456789',
                      email: 'lihonggang11@h-partners.com',
                    })}
                  </Text>
                  <Button
                    key="openAction5"
                    title="系统分享多条文件路径"
                    onPress={async () => {
                      const res = await openAction({
                        title,
                        subject,
                        urls: [url, imageUrl, imageUrl2],
                        saveToFiles: false,
                        message: '短信消息',
                        recipient: '123456789',
                        email: 'lihonggang11@h-partners.com',
                      });
                      setState(res);
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>
   

         <TestSuite name="验证ShareOptions参数">
          <TestCase
            itShould="测试title参数"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text style={styles.inputView}>
                    ShareOptions支持title参数设置分享标题
                  </Text>
                  <Button
                    title="测试title参数"
                    onPress={async () => {
                      try {
                        const res = await RNShare.open({
                          title: '分享标题',
                          url: '',
                        });
                        setState(res.success);
                      } catch (error) {
                        console.log('###ShareOptions title error', error);
                        setState(false);
                      }
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase ShareOptions title', state);
              expect(state).to.be.true;
            }}
          />

          <TestCase
            itShould="测试subject参数"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text style={styles.inputView}>
                    ShareOptions支持subject参数设置分享主题
                  </Text>
                  <Button
                    title="测试subject参数"
                    onPress={async () => {
                      try {
                        const res = await RNShare.open({
                          subject: '分享主题',
                          message: '测试消息内容',
                          url: 'https://developer.huawei.com/consumer/cn/',
                        });
                        setState(res.success);
                      } catch (error) {
                        console.log('###ShareOptions subject error', error);
                        setState(false);
                      }
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase ShareOptions subject', state);
              expect(state).to.be.true;
            }}
          />

          <TestCase
            itShould="测试url参数"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text style={styles.inputView}>
                    ShareOptions支持url参数设置分享的文件地址
                  </Text>
                  <Button
                    title="测试url参数"
                    onPress={async () => {
                      try {
                        const res = await RNShare.open({
                          url: 'https://developer.huawei.com/consumer/cn/',
                        });
                        setState(res.success);
                      } catch (error) {
                        console.log('###ShareOptions url error', error);
                        setState(false);
                      }
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase ShareOptions url', state);
              expect(state).to.be.true;
            }}
          />

          <TestCase
            itShould="测试urls参数"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text style={styles.inputView}>
                    ShareOptions支持urls参数设置多个分享文件地址
                  </Text>
                  <Button
                    title="测试urls参数"
                    onPress={async () => {
                      try {
                        const res = await RNShare.open({
                          urls: [
                            'https://developer.huawei.com/consumer/cn/',
                            'https://developer.huawei.com/images/new-content/develop/img_DLP_develop_gailan_ArkUI.png'
                          ],
                        });
                        setState(res.success);
                      } catch (error) {
                        console.log('###ShareOptions urls error', error);
                        setState(false);
                      }
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase ShareOptions urls', state);
              expect(state).to.be.true;
            }}
          />

          <TestCase
            itShould="测试saveToFiles参数"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text style={styles.inputView}>
                    ShareOptions支持saveToFiles参数控制是否保存到本地文件
                  </Text>
                  <Button
                    title="测试saveToFiles参数"
                    onPress={async () => {
                      try {
                        const res = await RNShare.open({
                          url: 'https://developer.huawei.com/images/new-content/develop/img_DLP_develop_gailan_ArkUI.png',
                          saveToFiles: true,
                        });
                        setState(res.success);
                      } catch (error) {
                        console.log('###ShareOptions saveToFiles error', error);
                        setState(false);
                      }
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase ShareOptions saveToFiles', state);
              expect(state).to.be.true;
            }}
          />

          <TestCase
            itShould="测试message参数"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text style={styles.inputView}>
                    ShareOptions支持message参数设置分享的消息内容
                  </Text>
                  <Button
                    title="测试message参数"
                    onPress={async () => {
                      try {
                        const res = await RNShare.open({
                          message: '分享的消息内容',
                          url: 'https://developer.huawei.com/consumer/cn/',
                        });
                        setState(res.success);
                      } catch (error) {
                        console.log('###ShareOptions message error', error);
                        setState(false);
                      }
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase ShareOptions message', state);
              expect(state).to.be.true;
            }}
          />

          <TestCase
            itShould="测试recipient参数"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text style={styles.inputView}>
                    ShareOptions支持recipient参数设置接收者信息
                  </Text>
                  <Button
                    title="测试recipient参数"
                    onPress={async () => {
                      try {
                        const res = await RNShare.open({
                          recipient: '123456789',
                          message: '短信内容',
                          url: 'https://developer.huawei.com/consumer/cn/',
                        });
                        setState(res.success);
                      } catch (error) {
                        console.log('###ShareOptions recipient error', error);
                        setState(false);
                      }
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase ShareOptions recipient', state);
              expect(state).to.be.true;
            }}
          />

          <TestCase
            itShould="测试type参数"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text style={styles.inputView}>
                    ShareOptions支持type参数设置文件类型（如image/png）
                  </Text>
                  <Button
                    title="测试type参数"
                    onPress={async () => {
                      try {
                        const res = await RNShare.open({
                          type: 'image/png',
                          url: '',
                        });
                        setState(res.success);
                      } catch (error) {
                        console.log('###ShareOptions type error', error);
                        setState(false);
                      }
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase ShareOptions type', state);
              expect(state).to.be.true;
            }}
          />

          <TestCase
            itShould="测试filename参数"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text style={styles.inputView}>
                    ShareOptions支持filename参数设置文件名
                  </Text>
                  <Button
                    title="测试filename参数"
                    onPress={async () => {
                      try {
                        const res = await RNShare.open({
                          type: 'image/png',
                          filename: 'test_image',
                          url: '',
                        });
                        setState(res.success);
                      } catch (error) {
                        console.log('###ShareOptions filename error', error);
                        setState(false);
                      }
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase ShareOptions filename', state);
              expect(state).to.be.true;
            }}
          />

          <TestCase
            itShould="测试filenames参数"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text style={styles.inputView}>
                    ShareOptions支持filenames参数设置多个文件名
                  </Text>
                  <Button
                    title="测试filenames参数"
                    onPress={async () => {
                      try {
                        const res = await RNShare.open({
                          type: 'image/png',
                          filenames: ['test_image1', 'test_image2'],
                          urls: [
                            '',
                            ''
                          ],
                        });
                        setState(res.success);
                      } catch (error) {
                        console.log('###ShareOptions filenames error', error);
                        setState(false);
                      }
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase ShareOptions filenames', state);
              expect(state).to.be.true;
            }}
          />

          <TestCase
            itShould="测试failOnCancel参数"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text style={styles.inputView}>
                    ShareOptions支持failOnCancel参数控制取消时是否抛出异常
                  </Text>
                  <Button
                    title="测试failOnCancel参数"
                    onPress={async () => {
                      try {
                        const res = await RNShare.open({
                          message: '测试消息',
                          url: 'https://developer.huawei.com/consumer/cn/',
                          failOnCancel: false,
                        });
                        setState(res.success);
                      } catch (error) {
                        console.log('###ShareOptions failOnCancel error', error);
                        setState(false);
                      }
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase ShareOptions failOnCancel', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>
        <TestSuite name="验证open-excludedActivityTypes参数">
          <TestCase
            itShould="系统分享应用excludedActivityTypes参数"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text numberOfLines={10} style={styles.inputView}>
                    {JSON.stringify({
                      type: 'image/png',
                      url: base64Url,

                    })}
                  </Text>
                  <Button
                    key="openAction22"
                    title="系统分享Base64图片"
                    onPress={async () => {
                      if (excludedActivityTypes.length == 5) {
                        setExcludedActivityTypes(['0'])
                      } else {
                        setExcludedActivityTypes(['0', '1', '2', '3', '4'])
                      }
                      const res = await openAction({
                        type: 'image/png',
                        excludedActivityTypes: excludedActivityTypes,
                        url: base64Url,
                      });
                      setState(res);
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>
        <TestSuite name="验证open-saveToFiles参数">
          <TestCase
            itShould="系统分享应用保存到文件-saveToFiles参数"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text numberOfLines={10} style={styles.inputView}>
                    {JSON.stringify({
                      type: 'image/png',
                      saveToFiles: saveToFiles,
                      failOnCancel: true,
                      url: base64Url
                    })}
                  </Text>
                  <Button
                    key="openAction22"
                    title="系统分享Base64图片"
                    onPress={async () => {
                      if (saveToFiles) {
                        setSaveToFiles(false)
                      } else {
                        setSaveToFiles(true)
                      }

                      const res = await openAction({
                        type: 'image/png',
                        saveToFiles: saveToFiles,
                        failOnCancel: true,
                        url: base64Url
                      });
                      setState(res);
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>
        <TestSuite name="验证open-urls参数">
          <TestCase
            itShould="系统应用分享Base64图片-urls参数"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text numberOfLines={10} style={styles.inputView}>
                    {JSON.stringify({
                      type: 'image/png',
                      urls: [base64Url, base64Url],
                    })}
                  </Text>
                  <Button
                    key="openAction22"
                    title="系统分享Base64图片"
                    onPress={async () => {
                      const res = await openAction({
                        type: 'image/png',
                        urls: [base64Url, base64Url],

                      });
                      setState(res);
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>
        <TestSuite name="验证open-type参数">
          <TestCase
            itShould="系统应用分享视频-type参数"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text numberOfLines={10} style={styles.inputView}>
                    {JSON.stringify({
                      type: 'video/mp4',
                      url: videoUrl,
                    })}
                  </Text>
                  <Button
                    key="openAction3"
                    title="系统分享视频"
                    onPress={async () => {
                      const res = await openAction({
                        type: 'video/mp4',
                        url: videoUrl,
                      });
                      console.log('###分享结果111:', res);
                      // 可以在这里添加文件系统查询代码来验证文件位置
                      setState(res);
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>
        <TestSuite name="验证open-title参数">
          <TestCase
            itShould="系统应用分享-title参数"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text numberOfLines={10} style={styles.inputView}>
                    {JSON.stringify({
                      title,
                      url: base64Url,
                    })}
                  </Text>
                  <Button
                    key="openAction3"
                    title="系统分享Base64图片"
                    onPress={async () => {
                      const res = await openAction({
                        title,
                        url: base64Url,
                      });
                      setState(res);
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>
        <TestSuite name="验证open-subject参数">
          <TestCase
            itShould="系统应用分享-subject参数"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text numberOfLines={10} style={styles.inputView}>
                    {JSON.stringify({
                      subject,
                      url: base64Url,
                    })}
                  </Text>
                  <Button
                    key="openAction3"
                    title="系统分享Base64图片"
                    onPress={async () => {
                      const res = await openAction({
                        subject,
                        url: base64Url,
                      });
                      setState(res);
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>
        <TestSuite name="验证open-message参数">
          <TestCase
            itShould="系统应用分享-message参数"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text numberOfLines={10} style={styles.inputView}>
                    {JSON.stringify({
                      message: '短信消息',
                      url: base64Url,
                    })}
                  </Text>
                  <Button
                    key="openAction3"
                    title="系统分享Base64图片"
                    onPress={async () => {
                      const res = await openAction({
                        message: '短信消息',
                        url: base64Url,
                      });
                      setState(res);
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>
        <TestSuite name="验证open-recipient参数">
          <TestCase
            itShould="系统应用分享-recipient参数"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text numberOfLines={10} style={styles.inputView}>
                    {JSON.stringify({
                      recipient: '123456789',
                      url: base64Url,
                    })}
                  </Text>
                  <Button
                    key="openAction3"
                    title="系统分享Base64图片"
                    onPress={async () => {
                      const res = await openAction({
                        recipient: '123456789',
                        url: base64Url,
                      });
                      setState(res);
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>
        <TestSuite name="验证open-urls参数时设置filenams参数">
          <TestCase
            itShould="系统应用分享Base64图片-urls参数"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text numberOfLines={10} style={styles.inputView}>
                    {JSON.stringify({
                      type: 'image/png',
                      filenames: ['testaaa', 'testaaa2'],
                      urls: [base64Url, base64Url],
                    })}
                  </Text>
                  <Button
                    key="openAction22"
                    title="系统分享Base64图片"
                    onPress={async () => {
                      const res = await openAction({
                        type: 'image/png',
                        filenames: ['testaaa', 'testaaa2'],
                        urls: [base64Url, base64Url],

                      });
                      setState(res);
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>
        <TestSuite name="验证open-url参数">
          <TestCase
            itShould="系统应用分享Base64图片-url参数"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text numberOfLines={10} style={styles.inputView}>
                    {JSON.stringify({
                      type: 'image/png',
                      url: [base64Url],
                    })}
                  </Text>
                  <Button
                    key="openAction22"
                    title="系统分享Base64图片"
                    onPress={async () => {
                      const res = await openAction({
                        type: 'image/png',
                        url: base64Url,

                      });
                      setState(res);
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>
        <TestSuite name="验证open-url参数时设置filenam参数">
          <TestCase
            itShould="系统应用分享Base64图片-url参数"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text numberOfLines={10} style={styles.inputView}>
                    {JSON.stringify({
                      type: 'image/png',
                      filename: 'testaaa',
                      url: [base64Url],
                    })}
                  </Text>
                  <Button
                    key="openAction22"
                    title="系统分享Base64图片"
                    onPress={async () => {
                      const res = await openAction({
                        type: 'image/png',
                        filename: 'testaaa111',
                        url: base64Url,

                      });
                      setState(res);
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>

        <TestSuite name="验证open-failOnCancel参数">
          <TestCase
            itShould="系统分享应用取消时是否抛出异常-failOnCancel参数"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text numberOfLines={10} style={styles.inputView}>
                    {JSON.stringify({
                      message: '测试failOnCancel参数',
                      failOnCancel: false, // 设置为false，取消时不抛出异常
                      url: url
                    })}
                  </Text>
                  <Button
                    key="testFailOnCancelFalse"
                    title="测试failOnCancel=false"
                    onPress={async () => {
                      try {
                        const res = await openAction({
                          message: '测试failOnCancel参数',
                          failOnCancel: false,
                          url: url
                        });
                        // 即使用户取消分享，也不会抛出异常
                        setState(true);
                      } catch (error) {
                        console.log('###failOnCancel=false error', error);
                        setState(false);
                      }
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase failOnCancel=false', state);
              expect(state).to.be.true;
            }}
          />

          <TestCase
            itShould="系统分享应用取消时抛出异常-failOnCancel参数"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text numberOfLines={10} style={styles.inputView}>
                    {JSON.stringify({
                      message: '测试failOnCancel参数',
                      failOnCancel: true, // 设置为true，取消时抛出异常
                      url: url
                    })}
                  </Text>
                  <Button
                    key="testFailOnCancelTrue"
                    title="测试failOnCancel=true"
                    onPress={async () => {
                      try {
                        const res = await openAction({
                          message: '测试failOnCancel参数',
                          failOnCancel: true,
                          url: url
                        });
                        setState(res);
                      } catch (error) {
                        // 当用户取消分享时，会抛出异常
                        console.log('###failOnCancel=true error (expected)', error);
                        // 在这种情况下，我们认为抛出异常是正常的，所以仍然设置为true
                        setState(true);
                      }
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase failOnCancel=true', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>

        <TestSuite name="验证open-系统分享Base64图片">
          <TestCase
            itShould="true"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text numberOfLines={10} style={styles.inputView}>
                    {JSON.stringify({
                      type: 'image/png',
                      title,
                      filename: 'test',
                      subject,
                      url: base64Url,
                      message: '短信消息',
                      recipient: '123456789',
                      email: 'lihonggang11@h-partners.com',
                    })}
                  </Text>
                  <Button
                    key="openAction22"
                    title="系统分享Base64图片"
                    onPress={async () => {
                      if (excludedActivityTypes.length == 5) {
                        setExcludedActivityTypes(['0'])
                      } else {
                        setExcludedActivityTypes(['0', '1', '2', '3', '4'])
                      }
                      const res = await openAction({
                        type: 'image/png',
                        title,
                        filenames: ['test', 'test2'],
                        subject,
                        urls: [base64Url, base64Url],
                        failOnCancel: false,
                        excludedActivityTypes: excludedActivityTypes,
                        message: '短信消息',
                        recipient: '123456789',
                        email: 'lihonggang11@h-partners.com',
                      });
                      setState(res);
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>
        <TestSuite name="验证open-系统分享Base64图片">
          <TestCase
            itShould="true"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text numberOfLines={10} style={styles.inputView}>
                    {JSON.stringify({
                      type: 'image/png',
                      title,
                      filename: 'test',
                      subject,
                      url: base64Url,
                      message: '短信消息',
                      recipient: '123456789',
                      email: 'lihonggang11@h-partners.com',
                    })}
                  </Text>
                  <Button
                    key="openAction22"
                    title="系统分享Base64图片"
                    onPress={async () => {
                      if (excludedActivityTypes.length == 5) {
                        setExcludedActivityTypes(['0'])
                      } else {
                        setExcludedActivityTypes(['0', '1', '2', '3', '4'])
                      }
                      const res = await openAction({
                        type: 'image/png',
                        title,
                        filenames: ['test', 'test2'],
                        subject,
                        urls: [base64Url, base64Url],
                        failOnCancel: false,
                        excludedActivityTypes: excludedActivityTypes,
                        message: '短信消息',
                        recipient: '123456789',
                        email: 'lihonggang11@h-partners.com',
                      });
                      setState(res);
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>
        <TestSuite name="验证open-系统分享Base64图片">
          <TestCase
            itShould="true"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text numberOfLines={10} style={styles.inputView}>
                    {JSON.stringify({
                      type: 'image/png',
                      title,
                      filename: 'test',
                      subject,
                      url: base64Url,
                      message: '短信消息',
                      recipient: '123456789',
                      email: 'lihonggang11@h-partners.com',
                    })}
                  </Text>
                  <Button
                    key="openAction22"
                    title="系统分享Base64图片"
                    onPress={async () => {
                      if (excludedActivityTypes.length == 5) {
                        setExcludedActivityTypes(['0'])
                      } else {
                        setExcludedActivityTypes(['0', '1', '2', '3', '4'])
                      }
                      const res = await openAction({
                        type: 'image/png',
                        title,
                        filenames: ['test', 'test2'],
                        subject,
                        urls: [base64Url, base64Url],
                        failOnCancel: false,
                        excludedActivityTypes: excludedActivityTypes,
                        message: '短信消息',
                        recipient: '123456789',
                        email: 'lihonggang11@h-partners.com',
                      });
                      setState(res);
                    }}
                  />
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>


        <TestSuite name="验证Overlay组件-visible属性">
          <TestCase
            itShould="设置visible为true显示Overlay"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text style={styles.inputView}>
                    Overlay visible=true，直接显示
                  </Text>
                  <RNShare.Overlay visible={true}>
                    <View style={styles.container1}>
                      <TouchableOpacity style={styles.option}>
                        <Text>测试选项1</Text>
                      </TouchableOpacity>
                      <TouchableOpacity
                        style={styles.cancelOption}
                        onPress={() => setState(true)}>
                        <Text style={{ color: 'gray' }}>确认测试</Text>
                      </TouchableOpacity>
                    </View>
                  </RNShare.Overlay>
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase Overlay visible=true', state);
              expect(state).to.be.true;
            }}
          />
          <TestCase
            itShould="设置visible为false隐藏Overlay"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text style={styles.inputView}>
                    Overlay visible=false，不显示Overlay
                  </Text>
                  <Button
                    title="确认Overlay未显示"
                    onPress={() => setState(true)}
                  />
                  <RNShare.Overlay visible={false}>
                    <View style={styles.container1}>
                      <TouchableOpacity style={styles.option}>
                        <Text>测试选项1</Text>
                      </TouchableOpacity>
                    </View>
                  </RNShare.Overlay>
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase Overlay visible=false', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>
        <TestSuite name="验证Overlay组件-children属性">
          <TestCase
            itShould="Overlay可以渲染自定义children内容"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              const [overlayVisible2, setOverlayVisible2] = useState(false);
              return (
                <View style={styles.section}>
                  <Text style={styles.inputView}>
                    Overlay组件支持渲染自定义children内容
                    {"\n\n"}点击按钮显示带有自定义内容的Overlay
                  </Text>
                  <Button
                    key="overlayChildrenTest"
                    title="显示自定义Overlay内容"
                    onPress={() => {
                      setOverlayVisible2(true);
                      setState(true);
                    }}
                  />
                  <RNShare.Overlay visible={overlayVisible2}>
                    <View style={styles.container1}>
                      <Text style={{ fontSize: 18, fontWeight: 'bold', marginBottom: 10 }}>
                        自定义Overlay内容
                      </Text>
                      <TouchableOpacity style={styles.option}>
                        <Text>微信</Text>
                      </TouchableOpacity>
                      <TouchableOpacity style={styles.option}>
                        <Text>QQ</Text>
                      </TouchableOpacity>
                      <TouchableOpacity style={styles.option}>
                        <Text>Email</Text>
                      </TouchableOpacity>
                      <TouchableOpacity
                        style={styles.cancelOption}
                        onPress={() => setOverlayVisible2(false)}>
                        <Text style={{ color: 'gray' }}>取消</Text>
                      </TouchableOpacity>
                    </View>
                  </RNShare.Overlay>
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase Overlay children', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>
        <TestSuite name="验证ShareSheet组件-visible属性">
          <TestCase
            itShould="设置visible为true显示ShareSheet"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text style={styles.inputView}>
                    ShareSheet visible=true，直接显示
                  </Text>
                  <RNShare.ShareSheet visible={true} onCancel={() => { }}>
                    <TouchableOpacity style={styles.option} onPress={() => setState(true)}>
                      <Text>测试选项1</Text>
                    </TouchableOpacity>
                    <TouchableOpacity style={styles.cancelOption} onPress={() => setState(true)}>
                      <Text style={{ color: 'gray' }}>确认测试</Text>
                    </TouchableOpacity>
                  </RNShare.ShareSheet>
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase ShareSheet visible=true', state);
              expect(state).to.be.true;
            }}
          />
          <TestCase
            itShould="设置visible为false隐藏ShareSheet"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text style={styles.inputView}>
                    ShareSheet visible=false，不显示ShareSheet
                  </Text>
                  <Button
                    title="确认ShareSheet未显示"
                    onPress={() => setState(true)}
                  />
                  <RNShare.ShareSheet visible={false} onCancel={() => { }}>
                    <TouchableOpacity style={styles.option}>
                      <Text>测试选项1</Text>
                    </TouchableOpacity>
                  </RNShare.ShareSheet>
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase ShareSheet visible=false', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>
        <TestSuite name="验证ShareSheet组件-onCancel属性">
          <TestCase
            itShould="点击取消按钮触发onCancel事件"
            initialState={{ cancelled: false, cancelCount: 0 }}
            tags={['dev']}
            arrange={({ setState, state }) => {
              const [shareSheetVisible, setShareSheetVisible] = useState(false);
              return (
                <View style={styles.section}>
                  <Text style={styles.inputView}>
                    点击ShareSheet的取消按钮测试onCancel事件
                  </Text>
                  <View style={{ marginTop: 10, padding: 10, backgroundColor: '#f0f0f0', borderRadius: 5 }}>
                    <Text style={{ fontSize: 14, color: '#333' }}>
                      onCancel事件状态: {state.cancelled ? '已触发' : '未触发'}
                    </Text>
                    <Text style={{ fontSize: 14, color: '#333', marginTop: 5 }}>
                      取消次数: {state.cancelCount}
                    </Text>
                  </View>
                  <Button
                    title="显示ShareSheet"
                    onPress={() => setShareSheetVisible(true)}
                  />
                  <RNShare.ShareSheet
                    visible={shareSheetVisible}
                    onCancel={() => {
                      console.log('ShareSheet onCancel triggered');
                      setShareSheetVisible(false);
                      setState({ cancelled: true, cancelCount: state.cancelCount + 1 });
                    }}>
                    <TouchableOpacity style={styles.option}>
                      <Text>分享选项1</Text>
                    </TouchableOpacity>
                    <TouchableOpacity
                      style={styles.cancelOption}
                      onPress={() => {
                        setShareSheetVisible(false);
                        setState({ cancelled: true, cancelCount: state.cancelCount + 1 });
                      }}>
                      <Text style={{ color: 'gray' }}>取消</Text>
                    </TouchableOpacity>
                  </RNShare.ShareSheet>
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase ShareSheet onCancel', state);
              expect(state.cancelled).to.be.true;
            }}
          />
        </TestSuite>
        <TestSuite name="验证ShareSheet组件-style属性">
          <TestCase
            itShould="ShareSheet应用style样式"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              const [shareSheetVisible, setShareSheetVisible] = useState(false);
              return (
                <View style={styles.section}>
                  <Text style={styles.inputView}>
                    ShareSheet组件支持style自定义样式
                  </Text>
                  <Button
                    title="显示自定义样式ShareSheet"
                    onPress={() => setShareSheetVisible(true)}
                  />
                  <RNShare.ShareSheet
                    visible={shareSheetVisible}
                    onCancel={() => setShareSheetVisible(false)}
                    style={{
                      backgroundColor: '#FFF8DC',
                      borderRadius: 20,
                      padding: 20
                    }}>
                    <TouchableOpacity style={styles.option}>
                      <Text>分享选项1</Text>
                    </TouchableOpacity>
                    <TouchableOpacity
                      style={styles.cancelOption}
                      onPress={() => {
                        setShareSheetVisible(false);
                        setState(true);
                      }}>
                      <Text style={{ color: 'gray' }}>关闭</Text>
                    </TouchableOpacity>
                  </RNShare.ShareSheet>
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase ShareSheet style', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>
        <TestSuite name="验证ShareSheet组件-overlayStyle属性">
          <TestCase
            itShould="ShareSheet应用overlayStyle样式"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              const [shareSheetVisible, setShareSheetVisible] = useState(false);
              return (
                <View style={styles.section}>
                  <Text style={styles.inputView}>
                    ShareSheet组件支持overlayStyle自定义蒙层样式
                  </Text>
                  <Button
                    title="显示自定义蒙层ShareSheet"
                    onPress={() => setShareSheetVisible(true)}
                  />
                  <RNShare.ShareSheet
                    visible={shareSheetVisible}
                    onCancel={() => setShareSheetVisible(false)}
                    overlayStyle={{
                      backgroundColor: 'rgba(255, 0, 0, 0.3)'
                    }}>
                    <TouchableOpacity style={styles.option}>
                      <Text>分享选项1</Text>
                    </TouchableOpacity>
                    <TouchableOpacity
                      style={styles.cancelOption}
                      onPress={() => {
                        setShareSheetVisible(false);
                        setState(true);
                      }}>
                      <Text style={{ color: 'gray' }}>关闭</Text>
                    </TouchableOpacity>
                  </RNShare.ShareSheet>
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase ShareSheet overlayStyle', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>
        <TestSuite name="验证ShareSheet组件-children属性">
          <TestCase
            itShould="ShareSheet渲染自定义children内容"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              const [shareSheetVisible, setShareSheetVisible] = useState(false);
              return (
                <View style={styles.section}>
                  <Text style={styles.inputView}>
                    ShareSheet组件支持渲染自定义children内容
                  </Text>
                  <Button
                    title="显示自定义内容ShareSheet"
                    onPress={() => setShareSheetVisible(true)}
                  />
                  <RNShare.ShareSheet
                    visible={shareSheetVisible}
                    onCancel={() => setShareSheetVisible(false)}>
                    <View style={{ padding: 10 }}>
                      <Text style={{ fontSize: 18, fontWeight: 'bold', marginBottom: 10 }}>
                        自定义ShareSheet内容
                      </Text>
                      <TouchableOpacity style={styles.option}>
                        <Text>微信</Text>
                      </TouchableOpacity>
                      <TouchableOpacity style={styles.option}>
                        <Text>QQ</Text>
                      </TouchableOpacity>
                      <TouchableOpacity style={styles.option}>
                        <Text>Email</Text>
                      </TouchableOpacity>
                      <TouchableOpacity
                        style={styles.cancelOption}
                        onPress={() => {
                          setShareSheetVisible(false);
                          setState(true);
                        }}>
                        <Text style={{ color: 'gray' }}>取消</Text>
                      </TouchableOpacity>
                    </View>
                  </RNShare.ShareSheet>
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase ShareSheet children', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>
        <TestSuite name="验证Sheet组件-visible属性">
          <TestCase
            itShould="设置visible为true显示Sheet"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text style={styles.inputView}>
                    Sheet visible=true，直接显示
                  </Text>
                  <RNShare.Sheet visible={true}>
                    <View style={styles.container2}>
                      <TouchableOpacity style={styles.option} onPress={() => setState(true)}>
                        <Text>测试选项1</Text>
                      </TouchableOpacity>
                      <TouchableOpacity style={styles.cancelOption} onPress={() => setState(true)}>
                        <Text style={{ color: 'gray' }}>确认测试</Text>
                      </TouchableOpacity>
                    </View>
                  </RNShare.Sheet>
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase Sheet visible=true', state);
              expect(state).to.be.true;
            }}
          />
          <TestCase
            itShould="设置visible为false隐藏Sheet"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text style={styles.inputView}>
                    Sheet visible=false，不显示Sheet
                  </Text>
                  <Button
                    title="确认Sheet未显示"
                    onPress={() => setState(true)}
                  />
                  <RNShare.Sheet visible={false}>
                    <View style={styles.container2}>
                      <TouchableOpacity style={styles.option}>
                        <Text>测试选项1</Text>
                      </TouchableOpacity>
                    </View>
                  </RNShare.Sheet>
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase Sheet visible=false', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>
        <TestSuite name="验证Sheet组件-children属性">
          <TestCase
            itShould="Sheet渲染自定义children内容"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text style={styles.inputView}>
                    Sheet组件支持渲染自定义children内容
                  </Text>
                  <RNShare.Sheet visible={true}>
                    <View style={styles.container2}>
                      <Text style={{ fontSize: 18, fontWeight: 'bold', padding: 10, textAlign: 'center' }}>
                        自定义Sheet内容
                      </Text>
                      <TouchableOpacity style={styles.option}>
                        <Text>微信</Text>
                      </TouchableOpacity>
                      <TouchableOpacity style={styles.option}>
                        <Text>QQ</Text>
                      </TouchableOpacity>
                      <TouchableOpacity style={styles.option}>
                        <Text>Email</Text>
                      </TouchableOpacity>
                      <TouchableOpacity
                        style={styles.cancelOption}
                        onPress={() => {
                          setState(true);
                        }}>
                        <Text style={{ color: 'gray' }}>关闭</Text>
                      </TouchableOpacity>
                    </View>
                  </RNShare.Sheet>
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase Sheet children', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>
        <TestSuite name="验证Button组件-onPress属性">
          <TestCase
            itShould="点击Button触发onPress事件"
            initialState={{ pressed: false, pressCount: 0 }}
            tags={['dev']}
            arrange={({ setState, state }) => {
              return (
                <View style={styles.section}>
                  <Text style={styles.inputView}>
                    点击Button组件测试onPress事件
                  </Text>
                  <RNShare.Button
                    onPress={() => {
                      console.log('Button onPress triggered');
                      setState({ pressed: true, pressCount: state.pressCount + 1 });
                    }}
                    iconSrc={[]}
                    buttonStyle={styles.highlightButton}
                    textStyle={styles.customTextStyle}>
                    <Text style={{ color: 'white', fontWeight: 'bold' }}>点击测试onPress</Text>
                  </RNShare.Button>
                  <View style={{ marginTop: 10, padding: 10, backgroundColor: '#f0f0f0', borderRadius: 5 }}>
                    <Text style={{ fontSize: 14, color: '#333' }}>
                      onPress事件状态: {state.pressed ? '已触发' : '未触发'}
                    </Text>
                    <Text style={{ fontSize: 14, color: '#333', marginTop: 5 }}>
                      点击次数: {state.pressCount}
                    </Text>
                  </View>
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase Button onPress', state);
              expect(state.pressed).to.be.true;
            }}
          />
        </TestSuite>
        <TestSuite name="验证Button组件-iconSrc属性">
          <TestCase
            itShould="Button显示iconSrc图标"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text style={styles.inputView}>
                    Button组件支持iconSrc属性显示图标
                  </Text>
                  <RNShare.Button
                    onPress={() => {
                      console.log('Button with icon clicked');
                      setState(true);
                    }}
                    iconSrc={[]}
                    buttonStyle={styles.highlightButton}
                    textStyle={styles.customTextStyle}>
                    <Text style={{ color: 'white', fontWeight: 'bold' }}>带图标的按钮</Text>
                  </RNShare.Button>
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase Button iconSrc', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>
        <TestSuite name="验证Button组件-buttonStyle属性">
          <TestCase
            itShould="Button应用buttonStyle样式"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text style={styles.inputView}>
                    Button组件支持buttonStyle自定义按钮样式
                  </Text>
                  <RNShare.Button
                    onPress={() => {
                      console.log('Styled button clicked');
                      setState(true);
                    }}
                    iconSrc={[]}
                    buttonStyle={{
                      backgroundColor: '#FF5722',
                      borderColor: '#E64A19',
                      borderWidth: 3,
                      borderRadius: 15,
                      padding: 15
                    }}
                    textStyle={{ color: 'white', fontSize: 16 }}>
                    <Text style={{ color: 'white', fontWeight: 'bold' }}>自定义样式按钮</Text>
                  </RNShare.Button>
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase Button buttonStyle', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>
        <TestSuite name="验证Button组件-textStyle属性">
          <TestCase
            itShould="Button应用textStyle样式"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text style={styles.inputView}>
                    Button组件支持textStyle自定义文本样式
                  </Text>
                  <RNShare.Button
                    onPress={() => {
                      console.log('Text styled button clicked');
                      setState(true);
                    }}
                    iconSrc={[]}
                    buttonStyle={styles.highlightButton}
                    textStyle={{
                      color: 'white', fontSize: 20, fontStyle: 'italic', textAlign: 'center', verticalAlign: 'middle', fontWeight: 'bold'
                    }}>
                    <Text style={{ color: 'white', fontSize: 20, }}>自定义文本样式</Text>
                  </RNShare.Button>
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase Button textStyle', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>
        <TestSuite name="验证Button组件-children属性">
          <TestCase
            itShould="Button渲染自定义children内容"
            initialState={false}
            tags={['dev']}
            arrange={({ setState }) => {
              return (
                <View style={styles.section}>
                  <Text style={styles.inputView}>
                    Button组件支持渲染自定义children内容
                  </Text>
                  <RNShare.Button
                    onPress={() => {
                      console.log('Button with custom children clicked');
                      // setState(true);
                    }}
                    iconSrc={[]}
                    buttonStyle={styles.highlightButton}
                    textStyle={styles.customTextStyle}>
                    children={<View style={{ flexDirection: 'row', alignItems: 'center' }}>
                      <Text style={{ color: 'white', fontSize: 16, marginRight: 5 }}>★</Text>
                      <Text style={{ color: 'white', fontWeight: 'bold' }}>自定义内容</Text>
                      <Text style={{ color: 'white', fontSize: 16, marginLeft: 5 }}>★</Text>
                    </View>}
                  </RNShare.Button>
                </View>
              );
            }}
            assert={async ({ expect, state }) => {
              console.log('###testCase Button children', state);
              expect(state).to.be.true;
            }}
          />
        </TestSuite>
      </ScrollView>



      <ScrollView style={styles.content1}>
        <View style={styles.container}>
          <Button title="ShareSheet" onPress={handleOpenShareSheet} />
          <Button title="Sheet" onPress={handleOpenSheet} />
          <Button title="Overlay" onPress={handleOpenOverlay} />
          <RNShare.Button
            onPress={() => alert('自定义内容')}
            iconSrc={[]}
            buttonStyle={styles.highlightButton}
            textStyle={styles.customTextStyle}>
            <Text style={{ fontWeight: 'bold', alignItems: 'center' }}>Button</Text>
          </RNShare.Button>
        </View>
      </ScrollView>

      <RNShare.ShareSheet
        visible={showShareSheet}
        onCancel={handleCloseShareSheet}
        overlayStyle={styles.sheetContent}
        style={styles.sheetContent}>
        <TouchableOpacity style={styles.option}>
          <Text>微信</Text>
        </TouchableOpacity>

        <TouchableOpacity style={styles.option}>
          <Text>QQ</Text>
        </TouchableOpacity>

        <TouchableOpacity style={styles.option}>
          <Text>Email</Text>
        </TouchableOpacity>

        <TouchableOpacity style={styles.option}>
          <Text>短信</Text>
        </TouchableOpacity>

        <TouchableOpacity style={styles.cancelOption} onPress={handleCloseShareSheet}>
          <Text style={{ color: 'gray' }}>取消</Text>
        </TouchableOpacity>
      </RNShare.ShareSheet>

      <RNShare.Overlay
        visible={showOverlay}>
        <View style={styles.container1}>
          <TouchableOpacity style={styles.option}>
            <Text>微信</Text>
          </TouchableOpacity>

          <TouchableOpacity style={styles.option}>
            <Text>Email</Text>
          </TouchableOpacity>

          <TouchableOpacity style={styles.option}>
            <Text>短信</Text>
          </TouchableOpacity>

          <TouchableOpacity style={styles.cancelOption} onPress={handleCloseOverlay}>
            <Text style={{ color: 'gray' }}>取消</Text>
          </TouchableOpacity>

        </View>
      </RNShare.Overlay>

      <RNShare.Sheet
        visible={showSheet}>
        <View style={styles.container2}>
          <TouchableOpacity style={styles.option}>
            <Text>微信</Text>
          </TouchableOpacity>

          <TouchableOpacity style={styles.option}>
            <Text>QQ</Text>
          </TouchableOpacity>

          <TouchableOpacity style={styles.option}>
            <Text>短信</Text>
          </TouchableOpacity>

          <TouchableOpacity style={styles.cancelOption} onPress={handleCloseSheet}>
            <Text style={{ color: 'gray' }}>取消</Text>
          </TouchableOpacity>
        </View>
      </RNShare.Sheet>
    </Tester>
  );
}
const styles = StyleSheet.create({
  btn: {
    width: 60,
    height: 60,
    aspectRatio: 1,
  },
  content: {
    width: '100%',
  },
  section: {
    padding: 20,
    fontSize: 14,
  },
  linkView: {
    backgroundColor: '#f2f2f2',
    padding: 10,
    fontSize: 15,
    width: '100%',
  },
  linkContent: {
    display: 'flex',
    fontSize: 14,
    justifyContent: 'flex-start',
    flexWrap: 'wrap',
    gap: 10,
    height: 300,
    width: '100%',
  },
  linkText: {
    padding: 5,
    textAlign: 'center',
    borderColor: '#f2f2f2',
    borderWidth: 1,
    borderRadius: 2,
    fontSize: 14,
    color: '#555',
  },
  linkTextSelected: {
    color: '#0000FF',
    padding: 5,
    textAlign: 'center',
    fontSize: 15,
    fontWeight: 500,
    borderColor: '#0000FF',
    borderWidth: 1,
    borderRadius: 3,
  },
  tipText: {
    fontSize: 12,
    color: '#999',
  },
  input: {
    backgroundColor: '#fff',
    borderRadius: 5,
    paddingTop: 10,
    paddingBottom: 10,
    height: 50,
    textAlignVertical: 'top',
    paddingHorizontal: 10,
    paddingVertical: 10,
  },
  inputView: {
    backgroundColor: '#fff',
    borderRadius: 5,
    paddingTop: 10,
    paddingBottom: 10,
    height: 200,
    textAlignVertical: 'top',
    paddingHorizontal: 10,
    paddingVertical: 10,
  },
  title: {
    fontSize: 16,
    fontWeight: 'bold',
    padding: 10,
    color: '#fff',
  },
  colText: {
    padding: 5,
  },
  cloumnView: {
    padding: 10,
    fontSize: 14,
    height: 280,
    display: 'flex',
    justifyContent: 'flex-start',
    alignItems: 'stretch',
    flexDirection: 'column',
    columnGap: 10,
    backgroundColor: '#f2f2f2',
    borderRadius: 10,
  },
  rowView: {
    width: '100%',
    height: 450,
    display: 'flex',
    justifyContent: 'flex-start',
    alignItems: 'center',
    rowGap: 10,
    columnGap: 10,
    backgroundColor: 'white',
    flexWrap: 'wrap',
    flexDirection: 'row',
    borderRadius: 5,
    padding: 20,
  },
  Button: {
    marginBottom: 20,
  },
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },

  container1: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#fff'
  },

  container2: {
    backgroundColor: '#fff'
  },

  content1: {
    width: '100%',
    height: 500,
  },

  highlightButton: {
    backgroundColor: '#4CAF50',
    borderColor: '#45a049',
    borderWidth: 2,
    borderRadius: 10
  },

  customTextStyle: {
    color: 'white',
    fontSize: 18,
    fontWeight: '600',
    marginLeft: 5,
  },

  button: { backgroundColor: '#007AFF', padding: 15, borderRadius: 8 },
  buttonText: { color: 'white', fontWeight: 'bold' },
  sheetContent: { paddingHorizontal: 10 },
  option: { padding: 15, alignItems: 'center', borderBottomWidth: 1, borderBottomColor: '#fff' },
  cancelOption: { padding: 15, alignItems: 'center', marginTop: 10 },
});

// 使用 export 导出
export const displayName = "react-native-share";
export const framework = "React";
export const category = "UI";
export const title = "react-native-share";
export const documentationURL = "https://github.com/react-native-oh-library/react-native-share";
export const description = "Simple React Native share component.";

export const examples = [
  {
    title: "Share with default styling",
    render: function (): any {
      return <RNShareExample />;
    },
  },
];

